package com.xxxx.springbootsecurity02.exception;

import com.xxxx.springbootsecurity02.util.ResultJSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice("com.xxxx.springbootsecurity02")
@Slf4j
public class GlobalException {

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public ResultJSON handleException(RuntimeException e){
        //log.error("系统异常:",e);
        return ResultJSON.error("系统异常:"+e);
    }

    @ExceptionHandler(LoginException.class)
    @ResponseBody
    public ResultJSON handleException(LoginException e){
        return ResultJSON.error(e.getMessage());
    }

}
